package Chapter2.Comparing.c3;

public class Practice {
    public static void main(String[] args) {
        String str1 = "         TGA the game award. ";
        //str1.trim();
        System.out.println("-"+str1+"-");
        str1= myTrim(str1);
        System.out.println("-"+str1+"-");
    }

    public static String myTrim(String s) {
        int start = 0;
        int end = s.length()-1;

        while (start<=end && s.charAt(start)== ' ') {
            start++;
        }

        while (start<=end && s.charAt(end)==' ') {
            end--;
        }
        return s.substring(start,end+1);
    }
}
